﻿<views:TicketsView
    x:Class="SpaceNeedle.x6473.WindowsPhone.Views.Tickets"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:views="clr-namespace:SpaceNeedle.x6473.WindowsPhone.Views"
    xmlns:controls="clr-namespace:SpaceNeedle.x6473.WindowsPhone.Controls"
    xmlns:viewmodels="clr-namespace:SpaceNeedle.x6473.WindowsPhone.ViewModels"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True" shell:SystemTray.Opacity="0">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="28,17,0,28">
            <TextBlock Text="{Binding AppContent.Name}" Style="{StaticResource PhoneTextNormalStyle}" FontFamily="Segoe WP SemiLight"/>
            <TextBlock Text="{Binding StaticContent.Title}"  Margin="9,20,0,0" Style="{StaticResource PhoneTextTitle1Style}" FontFamily="Portable User Interface"/>
        </StackPanel>

        <ListBox x:Name="ticketsListBox" Grid.Row="1" Margin="28,0,0,0" ItemsSource="{Binding RequestItems}" SelectionChanged="OnTicketsListBox_SelectionChanged" Visibility="{Binding RequestItems, Converter={StaticResource InverseIEnumerableCountToVisibilityConverter}}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="0,0,0,20">
                        <StackPanel Orientation="Vertical" Background="{StaticResource PhoneAccentBrush}" >
                            <Border Width="96" Height="76" VerticalAlignment="Top">
                                <Image Source="{Binding RequestIcon}" Width="64" Height="64" Stretch="UniformToFill" VerticalAlignment="Center"/>
                            </Border>
                            <Border Background="#30000000" Height="30">
                                <TextBlock FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="White" Text="{Binding Status, Converter={StaticResource RequestItemStatusToStringConverter},ConverterParameter=true}" />
                            </Border>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Margin="10,0,0,0">
                            <TextBlock FontSize="30" Text="{Binding RequestTitle}" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Width="340"/>
                            <TextBlock FontSize="22" Text="{Binding Address}" FontWeight="Bold" TextWrapping="NoWrap" TextTrimming="WordEllipsis"  Width="340"/>
                            <TextBlock FontSize="22" Margin="0,0,0,0" Text="{Binding Description}" TextWrapping="NoWrap" TextTrimming="WordEllipsis" Width="340"/>
                            <toolkit:ContextMenuService.ContextMenu>
                                <toolkit:ContextMenu IsZoomEnabled="false">
                                    <toolkit:MenuItem Header="Compartilhar" Foreground="Black" Tag="{Binding}" 
                                                  Click="OnShareTicket_Click" />
                                </toolkit:ContextMenu>
                            </toolkit:ContextMenuService.ContextMenu>
                        </StackPanel>
                    </StackPanel>
                    
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Text="Não existem Protocolos disponíveis" Grid.Row="1" Visibility="{Binding RequestItems, Converter={StaticResource IEnumerableCountToVisibilityConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        </Grid>
        <ProgressBar Visibility="{Binding IsInProgress, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource ProgressStyle}" VerticalAlignment="Top" />
        <controls:NewtworkStatusControl/>

    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar Mode="Minimized" Opacity="1.0" IsMenuEnabled="True" IsVisible="True">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="uploadsMenuItem" Text="uploads" Click="OnUploadsMenuItem_Click"/>
                <shell:ApplicationBarMenuItem x:Name="aboutMenuItem" Text="sobre" Click="OnAboutMenuItem_Click"/>
                <shell:ApplicationBarMenuItem x:Name="signoutMenuItem" Text="sair" Click="OnSignOutMenuItem_Click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</views:TicketsView>